import { ithome } from "@/servers/crawler";
import { Link } from "react-router";

const items = [
  { key: "newest", label: "最新" },
  { key: "hot", label: "热评" },
  {
    key: "today",
    label: "日榜",
  },
  {
    key: "theWeek",
    label: "周榜",
  },
  {
    key: "theMonth",
    label: "月榜",
  },
];

const TABS = Object.freeze({
  newest: "newest",
  hot: "hot",
  today: "today",
  theWeek: "theWeek",
  theMonth: "theMonth",
});

/**
 * 根据tab返回获取的init数据
 * @param tab
 * @returns Init hot数据
 */
const getInitHotData = async (tab) => {
  switch (tab) {
    case TABS.hot:
      return await ithome.getHot();
    case TABS.theMonth:
      return await ithome.getMonthly();
    case TABS.theWeek:
      return await ithome.getWeekly();
    case TABS.today:
      return await ithome.getDaily();
  }
};

export { items, TABS, getInitHotData };
